package com.helmlabs.grouper.accounts.service;

import org.springframework.dao.DataAccessException;
import org.springframework.security.userdetails.UserDetails;
import org.springframework.security.userdetails.UsernameNotFoundException;

import com.helmlabs.grouper.accounts.AccountApplicationContext;
import com.helmlabs.grouper.accounts.dao.UserProfileDao;
import com.helmlabs.grouper.accounts.model.UserProfile;

public class SecurityManagerImpl implements SecurityManager {

	private UserProfileDao userProfileDao = (UserProfileDao)AccountApplicationContext.getInstance().getBean("userProfileDao");
	
	public UserDetails loadUserByUsername(String username)
			throws UsernameNotFoundException, DataAccessException {
		UserProfile profile = userProfileDao.getByUsername(username);
		if (profile==null)
			throw new UsernameNotFoundException(username + " was not found");
		return profile;
	}
	
	

}
